#include "auto_start.h"
#include <qdir.h>

AutoStartManager::AutoStartManager(QString application, QObject * parent)
	:QObject(parent)
{
	settings = new QSettings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat);
	this->application = application;
}

void AutoStartManager::setAutoStart()
{
	QString appPath = QCoreApplication::applicationFilePath();
	QString windowsAppPath = QDir::toNativeSeparators(appPath);
	settings->setValue(application, QString("\"%1\"").arg(windowsAppPath));
}

void AutoStartManager::cancelAutoStart()
{
	settings->remove(application);
}
